const Mock = require('mockjs')

const List = []
const count = 100

const baseContent = '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'

for (let i = 0; i < count; i++) {
  List.push(Mock.mock({
    id: '@increment',
    timestamp: +Mock.Random.date('T'),
    author: '@name',
    reviewer: '@first',
    title: '@title(5, 10)',
    content_short: 'mock data',
    content: baseContent,
    forecast: '@float(0, 100, 2, 2)',
    importance: '@integer(1, 3)',
    'type|1': ['CN', 'US', 'JP', 'EU'],
    'status|1': ['published', 'draft'],
    display_time: '@datetime',
    comment_disabled: true,
    pageviews: '@integer(300, 5000)',
    image_uri,
    platforms: ['a-platform'],
    busiOpportunityName: '黑龙江省哈尔滨市中国移动集团的一个很长很长名称的项目'
  }))
}

module.exports = [
  {
    url: '/api/head/data',
    type: 'post',
    response: _ => {
      return {
        "cityId": 1002,
        "cityName": "哈尔滨",
        "project": {
          "projectId": 2002,
          "total": 0.832,
          "selfPre": 0.664,
          "tongFuPre": 0.765,
          "ziYouPre": 0.83,
          "ziYanPre": 0.783,
          "jiaoFuPre": 0.836,
          "qianZhiPre": 0.682,
          "ydkPre": 0.456,
          "yywyPre": 0.754,
          "projectMgrPre": 0.789
        },
        "income": {
          "incomeId": 3002,
          "itIncome": 6433.0,
          "ctIncome": 643.0,
          "nIncome": 4632.0,
          "totalIncome": 11708.0
        },
        "mgr": {
          "mgrId": 4002,
          "ztPro": 200,
          "yjxPro": 200,
          "xsShangji": 300,
          "dyLxPro": 50,
          "ylProNone": 50,
          "zbDlx": 50,
          "lxDqy": 50,
          "jfDys": 3,
          "totalMgr": 903
        },
        "mgrThree": {
          "mgrIdThree": 5002,
          "tbProCount": 41,
          "sjZcFaCount": 42,
          "zbProCount": 43,
          "zbProAmount": 44,
          "sjZcPre": 63.2,
          "zbProSjPre": 45.8
        },
        "question": {
          "questionId": 6002,
          "yqPro": 69,
          "fjPro": 57,
          "yqJdPro": 54,
          "jtBz": 45,
          "yqJfPro": 42,
          "czJf": 39
        },
        "errors": {}
      }
    }
  },
  {
    url: '/doubleFive/selectAll',
    type: 'get',
    response: _ => {
      return [
        {
          cityId: '1001',
          cityName: '黑龙江省',
          "zbAmountPer": 0.975,
          "zbCountPer": 0.944
        }, 
        {
          cityId: '1015',
          cityName: '省政企',
          "zbAmountPer": 0.875,
          "zbCountPer": 0.844
        }, {
          cityId: '1002',
          cityName: '哈尔滨市‌',
          "zbAmountPer": 0.875,
          "zbCountPer": 0.744
        }, {
          cityId: '1003',
          cityName: '齐齐哈尔市',
          "zbAmountPer": 0.775,
          "zbCountPer": 0.844
        }, {
          cityId: '1004',
          cityName: '牡丹江市',
          "zbAmountPer": 0.675,
          "zbCountPer": 0.944
        }, {
          cityId: '1005',
          cityName: '佳木斯市',
          "zbAmountPer": 0.375,
          "zbCountPer": 0.744
        }, {
          cityId: '1006',
          cityName: '大庆市',
          "zbAmountPer": 0.975,
          "zbCountPer": 0.344
        }, {
          cityId: '1007',
          cityName: '伊春市‌',
          "zbAmountPer": 0.775,
          "zbCountPer": 0.444
        }, {
          cityId: '1008',
          cityName: '鸡西市‌',
          "zbAmountPer": 0.875,
          "zbCountPer": 0.644
        }, {
          cityId: '1009',
          cityName: '鹤岗市‌',
          "zbAmountPer": 0.475,
          "zbCountPer": 0.244
        }, {
          cityId: '1010',
          cityName: '双鸭山市',
          "zbAmountPer": 0.575,
          "zbCountPer": 0.344
        }, {
          cityId: '1011',
          cityName: '‌七台河市‌',
          "zbAmountPer": 0.675,
          "zbCountPer": 0.444
        }, {
          cityId: '1012',
          cityName: '绥化市‌',
          "zbAmountPer": 0.275,
          "zbCountPer": 0.744
        }, {
          cityId: '1013',
          cityName: '黑河市‌',
          "zbAmountPer": 0.375,
          "zbCountPer": 0.144
        }, {
          cityId: '1014',
          cityName: '大兴安岭',
          "zbAmountPer": 0.375,
          "zbCountPer": 0.444
        }
      ]
    }
  },
  {
    url: '/api/incomeQuestion/selectCollection',
    type: 'get',
    response: _ => {
      return [
        {
          "cityId": 1015,
          "cityName": "省政企",
          "planProjectCount": 108,
          "monthPlanAmount": 1900000.0,
          "monthActualAmount": 886761.0,
          "monthTotalComplete": 0.956
        },
        {
          "cityId": 1001,
          "cityName": "哈尔滨市",
          "planProjectCount": 100,
          "monthPlanAmount": 1000000.0,
          "monthActualAmount": -87676.0,
          "monthTotalComplete": 0.932
        }, {
          cityId: '1003',
          cityName: '齐齐哈尔市',
          "monthPlanAmount": 1901.0,
          "monthActualAmount": 886.0,
        }, {
          cityId: '1004',
          cityName: '牡丹江市',
        }, {
          cityId: '1005',
          cityName: '佳木斯市',
        }, {
          cityId: '1006',
          cityName: '大庆市',
        }, {
          cityId: '1007',
          cityName: '伊春市‌',
        }, {
          cityId: '1008',
          cityName: '鸡西市‌',
        }, {
          cityId: '1009',
          cityName: '鹤岗市‌',      
        }, {
          cityId: '1010',
          cityName: '双鸭山市',        
        }
      ]
    }
  },
  {
    url: '/shangJi',
    type: 'post',
    response: _ => {
      return [
        {
          cityId: '1002',
          cityName: '哈尔滨市‌',
         "chuBeiPer": 0.956,
          "zhuanHuanPer": 0.936,
          "qianZhiPer": 0.964,
          "louBuPer": 0.993,
          "fuPanPer": 0.963,
          "zeroZbQxPer": 0.987,
          "projectExpand": 0.996,
          "zbDoubleAmount": 245245,
          "zbDoubleCount": 15600,
          "divisionResult": 0.64525,
          "division": 0.6333
        }, {
          cityId: '1003',
          cityName: '齐齐哈尔市',
          "chuBeiPer": 0.0165,
          "zhuanHuanPer": 0.836,
          "qianZhiPer": 0.864,
          "louBuPer": 0.893,
          "fuPanPer": 0.863,
          "zeroZbQxPer": 0.887,
          "projectExpand": 0.896,
          "zbDoubleAmount": 235245,
          "zbDoubleCount": 990,
          "divisionResult": 0.64525,
          "division": 0.6333
        }, {
          cityId: '1004',
          cityName: '牡丹江市',
          "chuBeiPer": 0.756,
          "zhuanHuanPer": 0.736,
          "qianZhiPer": 0.764,
          "louBuPer": 0.793,
          "fuPanPer": 0.763,
          "zeroZbQxPer": 0.787,
          "projectExpand": 0.796,
          "zbDoubleAmount": 225245,
          "zbDoubleCount": 980,
          "divisionResult": 0.64525,
          "division": 0.6333
        }, {
          cityId: '1005',
          cityName: '佳木斯市',
          "chuBeiPer": 0.656,
          "zhuanHuanPer": 0.636,
          "qianZhiPer": 0.664,
          "louBuPer": 0.693,
          "fuPanPer": 0.663,
          "zeroZbQxPer": 0.687,
          "projectExpand": 0.696,
          "zbDoubleAmount": 215245,
          "zbDoubleCount": 970,
          "divisionResult": 0.64525,
          "division": 0.6333
        }, {
          cityId: '1006',
          cityName: '大庆市',
          "chuBeiPer": 0.556,
          "zhuanHuanPer": 0.536,
          "qianZhiPer": 0.564,
          "louBuPer": 0.593,
          "fuPanPer": 0.563,
          "zeroZbQxPer": 0.587,
          "projectExpand": 0.596,
          "zbDoubleAmount": 195245,
          "zbDoubleCount": 900,
          "divisionResult": 0.64525,
          "division": 0.6333
        }, {
          cityId: '1007',
          cityName: '伊春市‌',
          "chuBeiPer": 0.456,
          "zhuanHuanPer": 0.436,
          "qianZhiPer": 0.464,
          "louBuPer": 0.493,
          "fuPanPer": 0.463,
          "zeroZbQxPer": 0.487,
          "projectExpand": 0.496,
          "zbDoubleAmount": 185245,
          "zbDoubleCount": 890,
          "divisionResult": 0.64525,
          "division": 0.6333
        }, {
          cityId: '1008',
          cityName: '鸡西市‌',
          "chuBeiPer": 0.356,
          "zhuanHuanPer": 0.336,
          "qianZhiPer": 0.364,
          "louBuPer": 0.393,
          "fuPanPer": 0.363,
          "zeroZbQxPer": 0.387,
          "projectExpand": 0.396,
          "zbDoubleAmount": 175245,
          "zbDoubleCount": 765,
          "divisionResult": 0.64525,
          "division": 0.6333
        }, {
          cityId: '1009',
          cityName: '鹤岗市‌',
          "chuBeiPer": 0.256,
          "zhuanHuanPer": 0.236,
          "qianZhiPer": 0.264,
          "louBuPer": 0.293,
          "fuPanPer": 0.263,
          "zeroZbQxPer": 0.287,
          "projectExpand": 0.296,
          "zbDoubleAmount": 165245,
          "zbDoubleCount": 698,
          "divisionResult": 0.64525,
          "division": 0.6333
        }, {
          cityId: '1010',
          cityName: '双鸭山市',
          "chuBeiPer": 0.226,
          "zhuanHuanPer": 0.226,
          "qianZhiPer": 0.224,
          "louBuPer": 0.223,
          "fuPanPer": 0.223,
          "zeroZbQxPer": 0.227,
          "projectExpand": 0.226,
          "zbDoubleAmount": 155245,
          "zbDoubleCount": 605,
          "divisionResult": 0.64525,
          "division": 0.6333
        }, {
          cityId: '1011',
          cityName: '‌七台河市‌',
          "chuBeiPer": 0.00070,
          "zhuanHuanPer": 0.136,
          "qianZhiPer": 0.164,
          "louBuPer": 0.193,
          "fuPanPer": 0.163,
          "zeroZbQxPer": 0.187,
          "projectExpand": 0.196,
          "zbDoubleAmount": 145245,
          "zbDoubleCount": 546,
          "divisionResult": 0.64525,
          "division": 0.6333
        }
      ]
    }
  },
  {
    url: '/api/incomeQuestion',
    type: 'post',
    response: config => {
      const { importance, title, page = 1, limit = 20, sort } = config.query

      let mockList = List.filter(item => {
        if (importance && item.importance !== +importance) return false
        if (title && item.title.indexOf(title) < 0) return false
        return true
      })

      if (sort === '-id') {
        mockList = mockList.reverse()
      }

      const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))

      return {
          total: mockList.length,
          list: pageList
      }
    }
  },

  {
    url: '/vue-element-admin/article/detail',
    type: 'get',
    response: config => {
      const { id } = config.query
      for (const article of List) {
        if (article.id === +id) {
          return {
            code: 20000,
            data: article
          }
        }
      }
    }
  },

  {
    url: '/vue-element-admin/article/pv',
    type: 'get',
    response: _ => {
      return {
        code: 20000,
        data: {
          pvData: [
            { key: 'PC', pv: 1024 },
            { key: 'mobile', pv: 1024 },
            { key: 'ios', pv: 1024 },
            { key: 'android', pv: 1024 }
          ]
        }
      }
    }
  },
  {
    url: '/vue-element-admin/article/create',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  },
  {
    url: '/vue-element-admin/article/update',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }
]

